home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
SNIP9_91.ARJ
/
MKTONE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
879b
|
46 lines
/*
** MKTONE.C
*/
#include "uclock.h"
#include "sound.h"
static int usec_timeout(uclock_t start, uclock_t finish, uclock_t usecs)
{
if (usecs >= (finish - start))
return 0;
else return 1;
}
void dosound(int freq)
{
unsigned i;
outp(C8253, SETIMER);
i = (unsigned)freq%256;
outp(F8253, i);
i = (unsigned)freq/256;
outp(F8253, i);
}
void mktone(int freq, int update, unsigned delay)
{
uclock_t start;
if (0 == freq)
{
soundoff();
return;
}
dosound(freq);
if (update != UPDATE)
soundon();
if (delay == 0)
return;
start = usec_clock();
while (!usec_timeout(start, usec_clock(), 1000L * (long)delay))
;
if (update == TOGGLE)
soundoff();
}